﻿using System;
using System.Numerics;

class FibonacciSum
{
    static void Main()
    {
        //Exercise 7.
        //Write a program that reads a number N and calculates the sum of the first N members of the sequence of 
        //Fibonacci: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, …
        //Each member of the Fibonacci sequence (except the first two) is a sum of the previous two members.

        Console.Write("Enter the length of Fibonacci's sequence to get calculated:  ");
        int n = int.Parse(Console.ReadLine());
        BigInteger firstNumber = 0;
        BigInteger secondNumber = 1;
        BigInteger thirdNumber = firstNumber + secondNumber;
        BigInteger finalResult = firstNumber + secondNumber + thirdNumber;

        for (int i = 1; i <= n - 3; i++)
        {
            firstNumber = secondNumber;
            secondNumber = thirdNumber;
            thirdNumber = firstNumber + secondNumber;
            finalResult = finalResult + thirdNumber;
        }       
        Console.WriteLine(finalResult);



    }
}

